﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Game_Project
{
    class Node
    {
        public int X { get; set; }
        public int Y { get; set; }
        private Random rnd;

        public Node(int x, int y)
        {
            X = x;
            Y = y;
            rnd = new Random();
            //Thread.Sleep(100);
        }

        public void MoveUp()
        { Y--; }

        public void MoveDown()
        { Y++; }

        public void MoveLeft()
        { X--; }

        public void MoveRight()
        { X++; }

        public bool IsOnPossition(int positionX, int positionY)
        {
            if (X == positionX && Y == positionY)
                return true;
            return false;
        }

        public virtual void Move(Func<int, int, Position> positionStatus)
        {
            int randomMove = rnd.Next(1, 5);
            switch (randomMove)
            {
                case 1:
                    {
                        //MoveUp
                        if (positionStatus(X, Y - 1) == Position.Free)
                            //IsPositionFree(node.X, node.Y - 1) && gameField.IsOnField(node.X, node.Y - 1))
                            MoveUp();
                    }
                    break;

                case 2:
                    {
                        //MoveDown
                        if (positionStatus(X, Y + 1) == Position.Free)
                            //IsPositionFree(node.X, node.Y + 1) &&
                            //gameField.IsOnField(node.X, node.Y + 1))
                            MoveDown();
                    }
                    break;

                case 3:
                    {
                        //MoveLeft
                        if (positionStatus(X - 1, Y) == Position.Free)
                            //IsPositionFree(node.X - 1, node.Y) &&
                            //gameField.IsOnField(node.X - 1, node.Y))
                            MoveLeft();
                    }
                    break;

                case 4:
                    {
                        //MoveRight
                        if (positionStatus(X + 1, Y) == Position.Free)
                            //IsPositionFree(node.X + 1, node.Y) &&
                            //gameField.IsOnField(node.X + 1, node.Y))
                            MoveRight();
                    }
                    break;
            }
        }

        

    }

    class ConsoleNode : Node
    {
        public char NodeSymbol { get;  set; }
        public ConsoleColor NodeColor { get;  set; }

        public ConsoleNode(int x, int y, char nodeSymbol, ConsoleColor nodeColor)
            : base(x, y)
        {
            NodeSymbol = nodeSymbol;
            NodeColor = nodeColor;
        }

    }


        //enum MoveDirection
        //{
        //    Up,
        //    Down
        //}
    
}
